GtkPlacesView: check for network:// URI support before using it
authorРуслан Ижбулатов <lrn1986@gmail.com>
Sun, 1 May 2016 19:00:25 +0000 (19:00 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Sun, 1 May 2016 19:04:18 +0000 (19:04 +0000)
Specifically, this URI is not supported on Windows, but GFile will
do its "best" and turn it into GLocalFile("$pwd/network"), with
spectacularly bad results.

https://bugzilla.gnome.org/show_bug.cgi?id=765858

gtk/gtkplacesview.c

index 1b3660f5da1a6cade7a3614e20ed0bfc3a9cee74..19af4ed570215f9bdcdbfc9d28e4cdd908db465a 100644 (file)
@@ -19,6 +19,7 @@
 #include "config.h"
 
 #include <gio/gio.h>
+#include <gio/gvfs.h>
 #include <gtk/gtk.h>
 
 #include "gtkintl.h"
@@ -1004,8 +1005,19 @@ fetch_networks (GtkPlacesView *view)
 {
   GtkPlacesViewPrivate *priv;
   GFile *network_file;
+  const gchar * const *supported_uris;
+  gboolean found;
 
   priv = gtk_places_view_get_instance_private (view);
+  supported_uris = g_vfs_get_supported_uri_schemes (g_vfs_get_local ());
+
+  for (found = FALSE; !found && supported_uris && supported_uris[0]; supported_uris++)
+    if (g_strcmp0 (supported_uris[0], "network") == 0)
+      found = TRUE;
+
+  if (!found)
+    return;
+
   network_file = g_file_new_for_uri ("network:///");
 
   g_cancellable_cancel (priv->networks_fetching_cancellable);